// pages/peccancy/order-success.js
const app = getApp()
Page({
    data: {
        violationLst: [],
        finishList: [],
        statusObj: {
            1: "待报价",
            2: "待支付",
            3: "待处理",
            4: "待确认",
            5: "已完成",
            6: "已关闭",
        },
        more: false
    },
    onLoad: function(options) {
        this.setData(options)
        this.loadData()
    },
    loadData() {
        wx.showLoading({
            title: '加载中...',
        })
        app.http.post('rest/ticket/queryById.do', {
            data: this.data.id
        }).then(res => {
			res.obj.no_complete_points = Math.abs(res.obj.pointed - res.obj.points)
            // res.obj.progress = ((res.obj.pointed / res.obj.points) * 100).toFixed(2)
            // this.setData(res.obj)
            this.setData({
                detail: res.obj
            })
            wx.hideLoading()
        })
    },
    submit() {
        wx.showModal({
            title: '请确认本次代办业务已完成',
            content: '平台将支付给代办方服务费',
            cancelColor: '#007AFF',
            confirmColor: '#007AFF',
            success: res => {
                if (res.confirm) {
                    wx.showLoading({
                        title: '请稍等...',
                    })
                    app.http.post('rest/ticket/confirmSuccess.do', {
                        data: this.data.id,
                        showMsg: false
                    }).then(res => {
                        wx.redirectTo({
                            url: '../peccancy/pay-ok-tips',
                        })
                    })
                }
            }
        })
    },
    callPhone() {
        wx.makePhoneCall({
            phoneNumber: this.data.detail.quoteMember.mobile
        })
    },
    backindex() {
        const ps = getCurrentPages()
        wx.navigateBack({
            delta: ps.length
        })
    },
    more() {
        this.setData({
            more: !this.data.more
        })
    },
})